# Maintainer: Chris Gorman <chrisjohgorman@gmail.com>


_realname=mathjax2
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.7.9
pkgrel=1
pkgdesc='An open source JavaScript display engine for mathematics that works in all modern browsers (mingw-w64)'
arch=(any)
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.mathjax.org/'
msys2_repository_url="https://github.com/mathjax/MathJax"
msys2_references=(
  'cpe: cpe:2.3:a:mathjax:mathjax'
)
license=(spdx:Apache-2.0)
source=("https://github.com/mathjax/MathJax/archive/$pkgver/$_realname-$pkgver.tar.gz")
sha256sums=('c9167279c87da044f2ff910ad573a02ce90354cb59440ae568eb86e1630f65df')

prepare() {
  cd "${srcdir}/Mathjax-${pkgver}"

# Remove unneeded stuff, see https://github.com/mathjax/MathJax-docs/wiki/Guide%3A-reducing-size-of-a-mathjax-installation
  rm -r docs test unpacked
  rm -r fonts/HTML-CSS/TeX/png
  for _format in eot otf svg ; do
    find . -type d -name "$_format" -prune -exec rm -rf {} \;
  done
}

package() {
  mkdir -p "$pkgdir${MINGW_PREFIX}"/share/{fonts,licenses/mathjax2}
  cp -a MathJax-$pkgver "$pkgdir${MINGW_PREFIX}"/share/mathjax2
  mv "$pkgdir${MINGW_PREFIX}"/share/mathjax2/fonts "$pkgdir${MINGW_PREFIX}"/share/fonts/mathjax2
  ln -s "$pkgdir${MINGW_PREFIX}"/share/fonts/mathjax2 "$pkgdir${MINGW_PREFIX}"/share/mathjax2/fonts
  mv "$pkgdir${MINGW_PREFIX}"/share/mathjax2/LICENSE "$pkgdir${MINGW_PREFIX}"/share/licenses/mathjax2/
}
